package com.dld.protocol.json;

import java.io.ByteArrayInputStream;

import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Element;

import android.content.Context;

import com.dld.android.net.Callback;
import com.dld.android.net.Param;
import com.dld.android.util.LogUtils;

public class CProtocol extends Protocol {

	public CProtocol(Context paramContext, String paramString1,
			String paramString2, Param paramParam) {
		this(paramContext, null, paramString1, paramString2, paramParam, true,
				true);
	}

	public CProtocol(Context paramContext, String type, String method,
			Param paramParam, boolean paramBoolean) {
		this(paramContext, null, type, method, paramParam, true, paramBoolean);
	}

	public CProtocol(Context paramContext, String host, String type,
			String method, Param paramParam, boolean paramBoolean1,
			boolean paramBoolean2) {
		super(paramContext, host, type, method, paramParam, paramBoolean1,
				paramBoolean2);
	}

	public String getAbsoluteUrl() {
		return getUrl() + getParam().toString();
	}

	public Callback getCallback() {
		Callback localCallback = super.getCallback();
		localCallback.custom = true;
		return localCallback;
	}

	public Param getParam() {
		if (this.param == null) {
			this.param = new Param();
			LogUtils.log("Protocol", "parame是空的");
		}
		return this.param;
	}

	public String getUrl() {
		String str = "http://shenzhen.dld.com/www/?";
		return str;

	}

	protected Object parse(String paramString) throws Exception {
		LogUtils.log("CProtocol", "parse执行了 " + paramString);
		Object localObject1 = this.onProtocolResult.getJsonBeanClass()
				.newInstance();
		try {
			Element localElement = DocumentBuilderFactory.newInstance()
					.newDocumentBuilder().parse(
							new ByteArrayInputStream(paramString
									.getBytes("UTF-8"))).getDocumentElement();
			return ((JsonBean) localObject1).parseXml(localElement);
		} catch (Exception localException) {
			localException.printStackTrace();
		}
		return null;
	}
}
